package com.xiaoc.bulldozer.common.dto;

import org.apache.commons.collections.CollectionUtils;

import java.util.List;

/**
 * 菜单节点
 * 
 * @author parcel
 * @date 2014-05-20 17:26:51
 */
public class MenuNode {
    
    private Node curNode;

	private List<Node> subNodeList;

	public Node getCurNode() {
		return curNode;
	}

	public void setCurNode(Node curNode) {
		this.curNode = curNode;
	}

	public List<Node> getSubNodeList() {
		return subNodeList;
	}

	public void setSubNodeList(List<Node> subNodeList) {
		this.subNodeList = subNodeList;
	}
	
	public boolean isMySon(String url) {
	    
	    if (CollectionUtils.isEmpty(this.subNodeList)) {
	        return false;
	    }
	    
	    for (Node subNode : this.subNodeList) {
            if (url.equals(subNode.url)) {
                return true;
            }
        }
	    
	    return false;
	}

	public static class Node {
		/**
		 * ID
		 */
		private Integer id;

		/**
		 * 功能名称
		 */
		private String name;

		/**
		 * 操作地址
		 */
		private String url;

		/**
		 * 权重
		 */
		private Integer weight;

		/**
		 * 是否为叶子节点
		 */
		private boolean leaf;

		public Integer getId() {
			return id;
		}

		public void setId(Integer id) {
			this.id = id;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public String getUrl() {
			return url;
		}

		public void setUrl(String url) {
			this.url = url;
		}

		public boolean isLeaf() {
			return leaf;
		}

		public void setLeaf(boolean leaf) {
			this.leaf = leaf;
		}

        /**
         * @return the weight
         */
        public Integer getWeight() {
            return weight;
        }

        /**
         * @param weight the weight to set
         */
        public void setWeight(Integer weight) {
            this.weight = weight;
        }
	}
}
